import * as dayjs from 'dayjs'
/**
 * 金额格式化
 * @param num
 * @returns
 */
export const formatMoney = (num: number | string) => {
  return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
/**
 * 金额格式化 只带钱币符号
 * @param num
 * @returns
 */
export const formatMoney2 = (num: number | string) => {
  const parseNum = parseFloat(num.toString())
  return parseNum.toLocaleString('zh-CN', { style: 'currency', currency: 'CNY' })
}

/**
 * 格式化时间
 * @param val
 * @param format
 * @returns
 */
export const formatDate = (val: number | string, template = 'YYYY-MM-DD HH:mm:ss') => {
  return dayjs(val).format(template)
}
